package com.xbongbong.lfasr.util;

import com.xbongbong.lfasr.exception.ConfigException;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;

public class PropConfig {
    public PropConfig() {
    }

    public static Map<String, String> LoadPoperties(String filePath) throws ConfigException {
        Map<String, String> poperties = new HashMap();
        if (filePath != null && !"".equals(filePath.trim())) {
            filePath = filePath.trim();
            InputStream is = PropConfig.class.getClassLoader().getResourceAsStream(filePath);
            Properties prop = new Properties();

            try {
                prop.load(is);
            } catch (IOException var9) {
                throw new ConfigException("The config file load ioexception");
            } catch (Exception var10) {
                throw new ConfigException("The config file load exception");
            }

            Set<Entry<Object, Object>> set = prop.entrySet();
            Iterator<Entry<Object, Object>> it = set.iterator();
            String key = null;
            String value = null;

            while(it.hasNext()) {
                Entry<Object, Object> entry = (Entry)it.next();
                key = String.valueOf(entry.getKey());
                value = String.valueOf(entry.getValue());
                key = key == null ? key : key.trim();
                value = value == null ? value : value.trim();
                poperties.put(key, value);
            }

            return poperties;
        } else {
            throw new ConfigException("The config file path is null");
        }
    }
}
